<?php

declare (strict_types=1);

namespace app\validate;

use think\Validate;

class Upload extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'image' => 'fileExt:jpg,jpeg,png,webp,gif,bmp|fileSize:20971520|fileMime:image/jpeg,image/png,image/bmp,image/gif,image/webp',
        'file' => 'fileExt:jpg,jpeg,png,webp,gif,bmp,zip,rar,pdf,doc,docx,xls,xlsx,ppt,pptx,txt,psd,mp3,mp4,wav,ogg,mov,webm,flac,weba,svg,ico,tar,gz|fileMime:text/plain,image/jpeg,image/svg+xml,image/webp,image/x-icon,image/png,image/bmp,image/gif,image/vnd.microsoft.icon,audio/mpeg,audio/wav,audio/x-wav,audio/ogg,audio/flac,audio/webm,video/mp4,video/webm,video/ogg,video/x-msvideo,video/quicktime,application/pdf,application/zip,application/vnd.rar,application/x-tar,application/gzip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'image.fileExt' => '图片文件扩展名不正确',
        'image.fileSize' => '图片大小不能超过20M',
        'image.fileMime' => '图片类型不正确',
        'file.fileExt' => '文档扩展名不允许上传',
        'file.fileMime' => '文档类型不允许上传',
    ];
}
